package com.hbpa.pan.server.modules.user.converter;

import com.hbpa.pan.server.modules.file.entity.RPanUserFile;
import com.hbpa.pan.server.modules.user.context.*;
import com.hbpa.pan.server.modules.user.entity.RPanUser;
import com.hbpa.pan.server.modules.user.po.*;
import com.hbpa.pan.server.modules.user.vo.UserInfoVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

/**
 * @author: BlcakTiger
 * @date: 2023/10/22 11:08
 * @contact: hsf6661@163.com
 * @description: 用户模块实体转化工具类
 */
@Mapper( componentModel = "spring")
public interface UserConverter {

    /**
     * UserRegisterPO转换成UserRegisterContext
     * @param userRegisterPO 用户注册参数对象
     * @return
     */
    UserRegisterContext userRegisterPO2UserRegisterContext(UserRegisterPO userRegisterPO);

    /**
     *UserRegisterContext转化为RPanUser
     * @param userRegisterContext 用户注册上下文对象
     * @return
     */
    @Mapping(target = "password",ignore = true)
    RPanUser userRegisterContext2RPanUser(UserRegisterContext userRegisterContext);

    /**
     * userLoginPO转化成UserLoginContext
     * @param userLoginPO 用户登录参数对象
     * @return
     */
    UserLoginContext userLoginPO2UserLoginContext(UserLoginPO userLoginPO);

    /**
     * CheckUsernamePO转化成CheckUsernameContext
     *
     * @param checkUsernamePO 用户忘记密码-校验用户名PO对象
     * @return
     */
    CheckUsernameContext checkUsernamePO2CheckUsernameContext(CheckUsernamePO checkUsernamePO);

    /**
     * CheckUsernamePO转化成CheckAnswerContext
     *
     * @param checkAnswerPO
     * @return
     */
    CheckAnswerContext checkAnswerPO2CheckAnswerContext(CheckAnswerPO checkAnswerPO);

    /**
     * ResetPasswordPO转化成ResetPasswordContext
     * @param resetPasswordPO
     * @return
     */
    ResetPasswordContext resetPasswordPO2ResetPasswordContext(ResetPasswordPO resetPasswordPO);

    /**
     * ChangePasswordPO转化成ChangePasswordContext
     *
     * @param changePasswordPO
     * @return
     */
    ChangePasswordContext changePasswordPO2ChangePasswordContext(ChangePasswordPO changePasswordPO);

    /**
     * 使用RPanUser和RPanUserFile组装UserInfoVO
     * @param rPanUser
     * @param rPanUserFile
     * @return
     */
    @Mapping(source = "rPanUser.username",target = "username")
    @Mapping(source = "rPanUserFile.parentId",target = "rootFileId")
    @Mapping(source = "rPanUserFile.filename",target = "rootFilename")
    UserInfoVO assembleUserInfoVO(RPanUser rPanUser, RPanUserFile rPanUserFile);
}
